from openpyxl import load_workbook

class ExcelUtils:
    def __init__(self,file,sheet_name):
        self.file = file
        self.wb = load_workbook(file)
        self.sheet = self.wb[sheet_name]

    def read(self):
        one = [i.value for i in self.sheet[1]]
        data = []
        for row in self.sheet.iter_rows(min_row=2,values_only=True):
            data.append(dict(zip(one,row)))
        return data

    def write(self,row,col,value):
        self.sheet.cell(row=row, column=col, value=value)
        self.wb.save(self.file)

    def close(self):
        self.wb.close()



